<%-- 
    Document   : busqueda
    Created on : Jan 21, 2013, 10:20:55 PM
    Author     : pcsijbug
--%>
<%@page import="beans.producto"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Busqueda</title>

        <LINK REL=StyleSheet href="style/Estilos.css" TYPE="text/css" />
        
        <script>
            
            function f_listar(){
                
                //alert("buscar");
                
                var context = "<%= request.getContextPath()%>";
               
                
                document.form1.hValor.value = "b";
                
                //document.form1.txtBuscar.value = "";
                
                document.form1.action = context+"/Buscarproducto";
                document.form1.method="POST";
                document.form1.submit();
                
                
            }
            
            function abrirAgregar(){
                
                var context = "<%= request.getContextPath()%>";
                
                
                window.open(context+"/AgregarProyecto.jsp", 'agregar', 'strWindowFeatures');
                
            }
            
            function f_modficar(valor){
                
                //alert(valor + "  ---- Franco");
                
                var context = "<%= request.getContextPath()%>";
                var codigo = valor;
                
                window.open(context+"/Buscarproducto?hValor=m&vcod=" + codigo, 'modificar', 'strWindowFeatures');

  
                
            }
            
            function buscar(){
                
                var context = "<%= request.getContextPath()%>";
                
                var txt = document.form1.txtBuscar.value;
                
                if(txt == ""){
                    alert("Ingresar busqueda");
                    return false;
                }
                    
               
                document.form1.hValor.value = "b";
                
                document.form1.action = context+"/Buscarproducto";
                document.form1.method="POST";
                document.form1.submit();
                
            }
            
            function agregar(){
                
                var context = "<%= request.getContextPath()%>";
                
                document.form1.action = context+"/agregarProforma";
                document.form1.method="POST";
                document.form1.submit();
                
            }
            
            
            function seleccionarArancel(nombreComponente){
                
                var algo = document.getElementById(nombreComponente);
                
                if (algo.checked){
                    
                    algo.value = "1";
                    
                }else{
                   
                    algo.value = "0";
                }
                
               
                
            }
            
        </script>



    <body>
        <div id="stylized" class="myform">
            <form id="form1" name="form1" method="post" action="">
                <%

                    String txtBuscar = "";
                    if (request.getAttribute("txtBuscar") != null) {
                        txtBuscar = (String) request.getAttribute("txtBuscar");
                    }
                %>    
                <table width="100%" border="0">

                    <TR>
                        <TD colspan="3">
                            <h1>Buscar por Descripcion</h1>
                            
                        </TD>
                    </TR>

                    <tr>
                        <td width="10%">

                            <label>Buscar
                                <span class="small">Descripcion</span>
                            </label>

                        </td>
                        <td width="10%">
                            <input type="text" id="txtBuscar" name="txtBuscar" value="<%= txtBuscar%>" />
                        </td>
                        <td width="80%" >
                            <button type="button" name="Submit" onclick="javascript:buscar()">Buscar</button>
                            <button type="button" name="Submit" onclick="javascript:abrirAgregar()" >Agregar</button>
                        </td>
                    </tr>

                </table>


                <div>

                    <table id="table-4" class="table-4" >
                        <tr>

                            <td>PRODUCT_ID</td>
                            <td>MANUFACTURER_ID</td>
                            <td>PRODUCT_CODE </td>
                            <td>PURCHASE_COST</td>
                            <td>QUANTITY_ON_HAND</td>
                            <td>MARKUP</td>
                            <td>AVAILABLE</td>
                            <td>DESCRIPTION</td>
                        </tr>

                        <%

                            if (request.getAttribute("listaProducto") != null) {

                                List lista = (List) request.getAttribute("listaProducto");

                                for (int i = 0; i < lista.size(); i++) {

                                    producto prd = (producto) lista.get(i);
                        %>

                        <tr>

                            <td>
                                <a onclick="f_modficar(<%= prd.getPRODUCT_ID()%>)" href="#" id="codigo<%= i%>" ><%= prd.getPRODUCT_ID()%></a>
                            </td>

                            <td> <%= prd.getMANUFACTURER_ID()%> </td>
                            <td> <%= prd.getPRODUCT_CODE()%> </td>
                            <td><%= prd.getPURCHASE_COST()%></td>
                            <td><%= prd.getQUANTITY_ON_HAND()%></td>
                            <td><%= prd.getMARKUP()%></td>
                            <td><%= prd.getAVAILABLE()%></td>
                            <td><%= prd.getDESCRIPTION()%></td>

                            <%}%>
                        <input type="hidden" name="totalListaRecuperada" value="<%=request.getAttribute("totalProdcutoConsulta")%>"
                               <input type="hidden" name="totalListaRecuperadaHugo" value="<%= lista.size()%>"

                               <% }%>
                    </table>

                    <input type="hidden" id="hValor" name="hValor" />
                    <label id="lblResulatado" name="lblResulatado" ></label>

                </div>
            </form>
        </div>


    </body>
</html>
